package com.cleaningcloud.erp.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cleaningcloud.erp.domain.dto.ErpProcudeReturnDto;
import com.cleaningcloud.erp.domain.vo.ErpProcudeReturnVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.erp.domain.ErpProcudeReturn;
import com.cleaningcloud.erp.service.IErpProcudeReturnService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 采购退换货Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-05
 */
@RestController
@RequestMapping("/ErpProcudeReturn")
public class ErpProcudeReturnController extends BaseController
{
    @Autowired
    private IErpProcudeReturnService erpProcudeReturnService;

    /**
     * 查询采购退换货列表
     */
    @RequiresPermissions("erp:ErpProcudeReturn:list")
    @GetMapping("/list")
    public TableDataInfo list(ErpProcudeReturnDto erpProcudeReturn)
    {
        startPage();
        List<ErpProcudeReturnVo> list = erpProcudeReturnService.selectErpProcudeReturnList(erpProcudeReturn);
        return getDataTable(list);
    }

    /**
     * 导出采购退换货列表
     */
    @RequiresPermissions("erp:ErpProcudeReturn:export")
    @Log(title = "采购退换货", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ErpProcudeReturnDto erpProcudeReturn)
    {
        List<ErpProcudeReturnVo> list = erpProcudeReturnService.selectErpProcudeReturnList(erpProcudeReturn);
        ExcelUtil<ErpProcudeReturnVo> util = new ExcelUtil<ErpProcudeReturnVo>(ErpProcudeReturnVo.class);
        util.exportExcel(response, list, "采购退换货数据");
    }

    /**
     * 获取采购退换货详细信息
     */
    @RequiresPermissions("erp:ErpProcudeReturn:query")
    @GetMapping(value = "/{procudeReturnId}")
    public AjaxResult getInfo(@PathVariable("procudeReturnId") Long procudeReturnId)
    {
        return success(erpProcudeReturnService.selectErpProcudeReturnByProcudeReturnId(procudeReturnId));
    }

    /**
     * 新增采购退换货
     */
    @RequiresPermissions("erp:ErpProcudeReturn:add")
    @Log(title = "采购退换货", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ErpProcudeReturnDto erpProcudeReturn)
    {
        return toAjax(erpProcudeReturnService.insertErpProcudeReturn(erpProcudeReturn));
    }

    /**
     * 修改采购退换货
     */
    @RequiresPermissions("erp:ErpProcudeReturn:edit")
    @Log(title = "采购退换货", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ErpProcudeReturnDto erpProcudeReturn)
    {
        return toAjax(erpProcudeReturnService.updateErpProcudeReturn(erpProcudeReturn));
    }

    /**
     * 修改销售退换货
     */
    @RequiresPermissions("erp:ErpProcudeReturn:audit")
    @Log(title = "销售退换货审核", businessType = BusinessType.UPDATE)
    @PutMapping("/audit")
    public AjaxResult audit(@RequestBody ErpProcudeReturn erpProcudeReturn)
    {
        return toAjax(erpProcudeReturnService.auditErpProcudeReturn(erpProcudeReturn));
    }

    /**
     * 删除采购退换货
     */
    @RequiresPermissions("erp:ErpProcudeReturn:remove")
    @Log(title = "采购退换货", businessType = BusinessType.DELETE)
	@DeleteMapping("/{procudeReturnIds}")
    public AjaxResult remove(@PathVariable Long[] procudeReturnIds)
    {
        return toAjax(erpProcudeReturnService.deleteErpProcudeReturnByProcudeReturnIds(procudeReturnIds));
    }
}
